package com.example.feitiansys.controller;

import com.example.feitiansys.pojo.Leave;
import com.example.feitiansys.pojo.Overtime;
import com.example.feitiansys.service.overtime.OvertimeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 加班申请
 */
@Controller
public class OverTimeController {
    @Resource
    private OvertimeService overtimeService;
    @RequestMapping("/system/overtime/update")
    public String update(){
        return "/system/overtime/update";
    }
    @RequestMapping("/system/overtime")
    public String overtimeshow(){
        return "system/overtime/overtime";
    }
    @RequestMapping("/system/overtime/add")
    public String overtimeaddshow(){
        return "system/overtime/add";
    }
    @RequestMapping("/system/overtime/getovertimes")
    @ResponseBody
    public Object getovertimes(Overtime overtime){
        if (overtime==null){
            overtime=new Overtime();
        }
        return overtimeService.queryAll(overtime) ;
    }
    @RequestMapping("/system/overtime/removes")
    @ResponseBody
    public Object removeovertimes(String array){
        String[] split = array.split(",");
        return overtimeService.deleteByIds(split);
    }
    @RequestMapping("/system/overtime/remove")
    @ResponseBody
    public Object removeovertime(Integer id){
        return overtimeService.deleteById(id);
    }
    @RequestMapping("/system/overtime/doadd")
    @ResponseBody
    public int overtimedoadd(Overtime overtime){
        Date date=new Date();
        overtime.setCreateTime(date);
        int insert = overtimeService.insert(overtime);
        return insert;
    }
    @RequestMapping("/system/overtime/getovertimebyid")
    @ResponseBody
    public Object getovertimebyid(Integer id){
        return overtimeService.queryById(id);
    }
    @RequestMapping("/system/overtime/doupdate")
    @ResponseBody
    public Object update(Overtime overtime){
        return overtimeService.update(overtime);
    }
}
